derived_est_table <- function(){
  
  rownames <- c("\\quad No dependent, under-50 ",
                "",
                "\\quad With dependent(s), under-50",
                "",
                "\\quad No dependent, over-50",
                "",
                "\\quad With dependent(s), over-50",
                "",
                "\\quad Constant",
                "", 
                "\\quad Constant",
                "",
                "\\quad Constant",
                "")
  
  table_list <- list()
  directories <- c("lowrisk_simplemh_censor0.2_main", 
                   "lowrisk_simplemh_censor0.5_main", 
                   "lowrisk_simplemh_censor0.2_switcher", 
                   "lowrisk_simplemh_censor0.5_switcher")
  for(i in directories){
    table_list[[i]] <- read.csv(paste0("../release/derived_paramests/specs/", i, "/derived.csv"))
  }
  
  table <- matrix(nrow = length(rownames), ncol = length(table_list))
  for(i in seq_along(table_list)){
      table[, i] <- perfectshuffle(table_list[[i]][, 3], 
                                   table_list[[i]][, 4])
  }
  # reshuffle in order we want: 
  table <- table[, c(1, 2, 3, 4)]
  
  MakeLatexTableAdj(
    startcodelist = list(
      "\\begin{table}[H]",
      "\\centering",
      "\\begin{tabular}{lcccc}",
      "&  &  &  & \\tabularnewline",
      "\\hline", 
      "\\hline", 
      " \\textbf{Household type} & \\multicolumn{2}{c}{\\textbf{Main}} & \\multicolumn{2}{c}{\\textbf{Switchers}}\\tabularnewline",
      "& \\textbf{(1)} & \\textbf{(2)} & \\textbf{(1)} & \\textbf{(2)}\\tabularnewline", 
      "\\hline", 
      "$\\omega_i$ &  &  & & \\tabularnewline"), 
    tableinnardslist = list(
      table[9:10, ], 
      table[11:12, ], 
      table[13:14, ]), 
    rownames = list(
      rownames[9:10], 
      rownames[11:12], 
      rownames[13:14]),
    stderrlist = list(T, T, T, T),
    tableinnardsroundvec = c(3, 3, 3, 3), 
    inbetweencodelistlist = list(
      list("\\hline", 
           "$\\psi_i$ &  &  &  & \\tabularnewline"),
      list("\\hline", 
           "Loss interpretation of $\\psi_i$ &  &  &  & \\tabularnewline")
    ),
    endcodelist = list(
      "\\hline",
      "\\multicolumn{1}{c}{$\\underline{c}$} & \\$20 & \\$50 & \\$20 & \\$50\\tabularnewline",
      "\\multicolumn{1}{c}{$N$} & \\multicolumn{2}{c}{512,515} & \\multicolumn{2}{c}{383,036}\\tabularnewline",
      "\\hline",
      "\\hline",
      "\\end{tabular}\\caption{Derived estimates: moral hazard and risk aversion} \\label{tab:main_t_derived_est}",
      "\\end{table}")
  )
}
